package com.hk.yajin.function.news;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.hk.developmentlib.utills.UiUtil;
import com.hk.yajin.R;
import com.hk.yajin.model.LunBoData;
import com.hk.yajin.model.News;
import com.jude.rollviewpager.RollPagerView;
import com.jude.rollviewpager.adapter.DynamicPagerAdapter;
import com.jude.rollviewpager.adapter.LoopPagerAdapter;
import com.jude.rollviewpager.adapter.StaticPagerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 伦哥哥 on 2017/6/25.
 */

public class NewsHeadViewAdapter extends LoopPagerAdapter {
    private List<LunBoData> data = new ArrayList<>();
    private Context context;

    public NewsHeadViewAdapter(List<LunBoData> images, Context activity, RollPagerView viewPager) {
        super(viewPager);
        data = images;
        context = activity;
    }


    @Override
    public View getView(ViewGroup viewGroup, int position) {
//        ImageView mContentView = new ImageView(context);
//        //mContentView.setImageResource(data.get(position).getId());
//        mContentView.setScaleType(ImageView.ScaleType.CENTER_CROP);
//        mContentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
//        Glide.with(context).load(data.get(position).getFullpic()).into(mContentView);


        View view = UiUtil.inflate(R.layout.list_head_lunbo);
        TextView tv_lunbo_item = (TextView) view.findViewById(R.id.tv_lunbo_item);
        if (!TextUtils.isEmpty(data.get(position).getAd_name())) {
            tv_lunbo_item.setText(data.get(position).getAd_name());
        } else {
            tv_lunbo_item.setText("");
        }
        ImageView iv_lunbo_item = (ImageView) view.findViewById(R.id.iv_lunbo_item);
        Glide.with(context).load(data.get(position).getAd_img()).placeholder(R.color.oriag2).error(R.color.app_line_eaeaea).into(iv_lunbo_item);
        return view;
    }


    @Override
    public int getRealCount() {
        return data.size();
    }


}
